# -*- coding: UTF-8 -*-
"""
@Project ：lufei-learning-city
@File    ：存储过程.py
@IDE     ：PyCharm
@Author  ：于金龙@阿龙的代码在报错
@Date    ：2024/9/22 下午6:29
"""
import pymysql

conn = pymysql.connect(
    host='localhost',
    port=3306,
    user='root',
    password='20020115',
    db='user',
    charset='utf8'
)
cursor = conn.cursor()

# cursor.callproc('p1')
# result = cursor.fetchall()

# cursor.callproc('p2', args=(1, 22, 3, 4))
# table = cursor.fetchall()
#
# cursor.execute('select @_p2_0,@_p2_1,@_p2_2,@_p2_3')
# result = cursor.fetchall()


# cursor.callproc('p3', args=(22, 3, 4))
# table = cursor.fetchall()  # 执行过程中的结果集
# # 获取执行完存储参数
# cursor.execute('select @_p3_0,@_p3_1,@_p3_2')
# result = cursor.fetchall()


cursor.callproc('p4', args=(100,))
cursor.execute("select @_p4_0")
result = cursor.fetchall()
cursor.close()
conn.close()
print(result)
